import paramiko

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())


def get_message_from_remote(commands):
    ssh.connect('172.19.100.15', 20343, "temporary", "q1w2e3r4t5")
    result = []
    for command in commands:
        stdin, stdout, stderr = ssh.exec_command(command)
        raw_result = stdout.readlines()
        raw_result = [item[:-1] for item in raw_result]
        result.append(raw_result)
    ssh.close()
    return result

# a = [1, 2, 3, 0, 4, 5, 6, 0, 7, 8, 9]
# b = []
# c = []
# for item in a:
#     if item == 0:
#         c.append(b)
#         b = []
#     else:
#         b.append(item)
# if len(b)>0:
#     c.append(b)
# print c


# print get_message_from_remote('ls /')
# line=''
# a=line.index('"PPC_DB_JOB')
# b=line.index(' ',a)
# line[a:b]
# "PPC_DB_JOB_PPDAI_THIRD_SUPPLIER_LOG"
# "PPC_DB_JOB_PPDAI_API_LOG"
# "PPC_DB_JOB_PPDAI_API_LOG_CONTENT"
# "PPC_DB_JOB_PPX_JD_DETAIL_LOG"
# print "PPC_DB_JOB_PPX_JD_REQUEST_LOG".lower()
